<template>
	<view>
		<view class="mainpadding_top">
			<view class="mainpadding_top">
				<view class="bigtext textcenter xiaohei fonweight">{{$t('gdgn.fwgl')}}</view>
				<view class="xiaohei textcenter margin_top2 sanshier">{{$t('gdgn.fwnr')}}</view>
			</view>
			<view class="" v-for="(item,index) in list" :key="index">
				<view class="xiahuaxian margin_top6 ershil xiaohui">{{item.typeName}}</view>
				<view class="xiahuaxian margin_top flexbetween" v-for="(ite) in item.list" :key="ite.id">
					<view class="flexleft">
						<image :src="ite.serviceImage" class="iconclass" mode=""></image>
						<view class="xiaohei ershiba nofonweight">{{ite.serviceName}}</view>
					</view>
					<u-switch inactiveColor="#999999" v-model="ite.showStatus" activeColor="#4b8dfd" @change="changevalue(ite)"></u-switch>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list: [],
				jdvalue:false
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init() {
				httpRequest.request('/api/v1/serviceType/listService', 'GET', {}).then(res => {
					res.data.forEach(item=>{
						item.list.forEach(ite=>{
							ite.showStatus = ite.showStatus==1?true:false
						})
					})
					this.list = res.data
				})
			},
			changevalue(value) {
				console.log(value);
				httpRequest.request('/api/v1/serviceType/setShow', 'GET', {
					showStatus:value.showStatus?1:2,
					serviceName:value.serviceName
				}).then(res => {
					this.userInfo = res.data
				})
			},
		}
	}
</script>

<style>
.iconclass{
	width: 60rpx;
	height: 60rpx;
	margin-right: 30rpx;
}
</style>